package com.test.slice;

import com.ms.banner.Banner;
import com.ms.banner.BannerConfig;
import com.test.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.DirectionalLayout;

import static com.test.MyApplication.getDataInt;
import static com.test.MyApplication.getDataStr;

public class CustomBannerAbilitySlice extends AbilitySlice {

    private Banner banner1, banner2, banner3;
    private DirectionalLayout directionalLayout;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_custom_banner);
        directionalLayout = (DirectionalLayout) findComponentById(ResourceTable.Id_dl_root);
        banner1 = (Banner) findComponentById(ResourceTable.Id_banner1);
        banner2 = (Banner) findComponentById(ResourceTable.Id_banner2);
        banner3 = (Banner) findComponentById(ResourceTable.Id_banner3);

        banner1.setAutoPlay(true)
                .setPages(getDataInt(), new CustomViewHolder())
                .start();

        banner2.setAutoPlay(true)
                .setPages(getDataInt(), new CustomViewHolder())
                .start();

        banner3.setBannerTitles(getDataStr())
                .setAutoPlay(true)
                .setPages(getDataInt(), new CustomViewHolder())
                .setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)
                .start();

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
